<?php

require_once('../lib/nusoap/nusoap.php');
include('../lib/log4php/Logger.php');
Logger::configure('../log/logconfig.xml');
include '../util/PrintArray.php';

include '../operation/UserProfileOperation.php';

$namespace = "UserProfileWebService";
$server = new soap_server();
$server->configureWSDL('UserProfileWebService', 'urn:UserProfileWebService');
$server->wsdl->schemaTargetNamespace = $namespace;
///////////////////////////////////////////////////////////////////////

// before create user profile
$server->wsdl->addComplexType(
        'createUserProfileRequestHeader'
        ,'complexType'
        ,'struct'
        ,'all'
        ,''
        ,array(  
            'refId'  => array('name' => 'refId','type' => 'xsd:string'),
            'dateTime'  => array('name' => 'dateTime','type' => 'xsd:string')
        )
);

$server->wsdl->addComplexType(
        'createUserProfileRequestDetail'
        ,'complexType'
        ,'struct'
        ,'all'
        ,''
        ,array(  
            'refId'  => array('name' => 'refId','type' => 'xsd:string'),
            'dateTime'  => array('name' => 'dateTime','type' => 'xsd:string'),
            'UserId' => array('name'=>'UserId','type'=>'xsd:string'),
            'Password'=>array('name'=>'Password','type'=>'xsd:string'),
            'GenderCode'=>array('name'=>'GenderCode','type'=>'xsd:string'),
            'TitleCode'=>array('name'=>'TitleCode','type'=>'xsd:string'),
            'FirstName'=>array('name'=>'FirstName','type'=>'xsd:string'),
            'MiddleName'=>array('name'=>'MiddleName','type'=>'xsd:string'),
            'LastName'=>array('name'=>'LastName','type'=>'xsd:string'),
            'Address1'=>array('name'=>'Address1','type'=>'xsd:string'),
            'Address2'=>array('name'=>'Address2','type'=>'xsd:string'),
            'Address3'=>array('name'=>'Address3','type'=>'xsd:string'),
            'Street'=>array('name'=>'Street','type'=>'xsd:string'),
            'SubDistrictCode'=>array('name'=>'SubDistrictCode','type'=>'xsd:string'),
            'DistrictCode'=>array('name'=>'DistrictCode','type'=>'xsd:string'),
            'ProvinceCode'=>array('name'=>'ProvinceCode','type'=>'xsd:string'),
            'PostCode'=>array('name'=>'PostCode','type'=>'xsd:string'),
            'Telephone'=>array('name'=>'Telephone','type'=>'xsd:string'),
            'MobilePhone'=>array('name'=>'MobilePhone','type'=>'xsd:string'),
            'CreateBy'=>array('name'=>'CreateBy','type'=>'xsd:string'),
            'UpdateBy'=>array('name'=>'UpdateBy','type'=>'xsd:string')
        )
);

$server->wsdl->addComplexType(
        'createUserProfileRequest'
        ,'complexType'
        ,'struct'
        ,'all'
        ,''
        ,array(
            'createUserProfileRequestHeader'=> array('name' => 'createUserProfileRequestHeader','type' => 'tns:createUserProfileRequestHeader'),
            'createUserProfileRequestDetail'  => array('name' => 'createUserProfileRequestDetail','type' => 'tns:createUserProfileRequestDetail')
        )
);

$server->wsdl->addComplexType(
        'createUserProfileResponseHeader'
        ,'complexType'
        ,'struct'
        ,'all'
        ,''
        ,array(  
            'refId'  => array('name' => 'refId','type' => 'xsd:string'),
            'dateTime'  => array('name' => 'dateTime','type' => 'xsd:string'),
            'responseCode'=>array('name'=>'responseCode','type'=>'xsd:string'),
            'responseDesc'=>array('name'=>'responseDesc','type'=>'xsd:string')
        )
);

$server->wsdl->addComplexType(
        'createUserProfileResponseDetail'
        ,'complexType'
        ,'struct'
        ,'all'
        ,''
        ,array(  
            'refId'  => array('name' => 'refId','type' => 'xsd:string'),
            'dateTime'  => array('name' => 'dateTime','type' => 'xsd:string'),
            'UserId' => array('name'=>'UserId','type'=>'xsd:string'),
            'GenderCode'=>array('name'=>'GenderCode','type'=>'xsd:string'),
            'TitleCode'=>array('name'=>'TitleCode','type'=>'xsd:string'),
            'FirstName'=>array('name'=>'FirstName','type'=>'xsd:string'),
            'MiddleName'=>array('name'=>'MiddleName','type'=>'xsd:string'),
            'LastName'=>array('name'=>'LastName','type'=>'xsd:string'),
            'Address1'=>array('name'=>'Address1','type'=>'xsd:string'),
            'Address2'=>array('name'=>'Address2','type'=>'xsd:string'),
            'Address3'=>array('name'=>'Address3','type'=>'xsd:string'),
            'Street'=>array('name'=>'Street','type'=>'xsd:string'),
            'SubDistrictCode'=>array('name'=>'SubDistrictCode','type'=>'xsd:string'),
            'DistrictCode'=>array('name'=>'DistrictCode','type'=>'xsd:string'),
            'ProvinceCode'=>array('name'=>'ProvinceCode','type'=>'xsd:string'),
            'PostCode'=>array('name'=>'PostCode','type'=>'xsd:string'),
            'Telephone'=>array('name'=>'Telephone','type'=>'xsd:string'),
            'MobilePhone'=>array('name'=>'MobilePhone','type'=>'xsd:string'),
            'CreateBy'=>array('name'=>'CreateBy','type'=>'xsd:string'),
            'CreateDate'=>array('name'=>'CreateDate','type'=>'xsd:string'),
            'UpdateBy'=>array('name'=>'UpdateBy','type'=>'xsd:string'),
            'UpdateDate'=>array('name'=>'UpdateDate','type'=>'xsd:string')
        )
);

$server->wsdl->addComplexType(
        'createUserProfileResponse'
        ,'complexType'
        ,'struct'
        ,'all'
        ,''
        ,array(
            'createUserProfileResponseHeader'=>array('name' => 'createUserProfileResponseHeader','type' => 'tns:createUserProfileResponseHeader'),
            'createUserProfileResponseDetail'=>array('name' => 'createUserProfileResponseDetail','type' => 'tns:createUserProfileResponseDetail')
        )
);

// end create user profile
// before update user profile

$server->wsdl->addComplexType(
        'updateUserProfileRequestHeader'
        ,'complexType'
        ,'struct'
        ,'all'
        ,''
        ,array(  
            'refId'  => array('name' => 'refId','type' => 'xsd:string'),
            'dateTime'  => array('name' => 'dateTime','type' => 'xsd:string')
        )
);

$server->wsdl->addComplexType(
        'updateUserProfileRequestDetail'
        ,'complexType'
        ,'struct'
        ,'all'
        ,''
        ,array(  
            'refId'  => array('name' => 'refId','type' => 'xsd:string'),
            'dateTime'  => array('name' => 'dateTime','type' => 'xsd:string'),
            'UserId' => array('name'=>'UserId','type'=>'xsd:string'),
            'GenderCode'=>array('name'=>'GenderCode','type'=>'xsd:string'),
            'TitleCode'=>array('name'=>'TitleCode','type'=>'xsd:string'),
            'FirstName'=>array('name'=>'FirstName','type'=>'xsd:string'),
            'MiddleName'=>array('name'=>'MiddleName','type'=>'xsd:string'),
            'LastName'=>array('name'=>'LastName','type'=>'xsd:string'),
            'Address1'=>array('name'=>'Address1','type'=>'xsd:string'),
            'Address2'=>array('name'=>'Address2','type'=>'xsd:string'),
            'Address3'=>array('name'=>'Address3','type'=>'xsd:string'),
            'Street'=>array('name'=>'Street','type'=>'xsd:string'),
            'SubDistrictCode'=>array('name'=>'SubDistrictCode','type'=>'xsd:string'),
            'DistrictCode'=>array('name'=>'DistrictCode','type'=>'xsd:string'),
            'ProvinceCode'=>array('name'=>'ProvinceCode','type'=>'xsd:string'),
            'PostCode'=>array('name'=>'PostCode','type'=>'xsd:string'),
            'Telephone'=>array('name'=>'Telephone','type'=>'xsd:string'),
            'MobilePhone'=>array('name'=>'MobilePhone','type'=>'xsd:string'),
            'UpdateBy'=>array('name'=>'UpdateBy','type'=>'xsd:string')
        )
);

$server->wsdl->addComplexType(
        'updateUserProfileRequest'
        ,'complexType'
        ,'struct'
        ,'all'
        ,''
        ,array(
            'updateUserProfileRequestHeader'=> array('name' => 'updateUserProfileRequestHeader','type' => 'tns:updateUserProfileRequestHeader'),
            'updateUserProfileRequestDetail'  => array('name' => 'updateUserProfileRequestDetail','type' => 'tns:updateUserProfileRequestDetail')
        )
);

$server->wsdl->addComplexType(
        'updateUserProfileResponseHeader'
        ,'complexType'
        ,'struct'
        ,'all'
        ,''
        ,array(  
            'refId'  => array('name' => 'refId','type' => 'xsd:string'),
            'dateTime'  => array('name' => 'dateTime','type' => 'xsd:string'),
            'responseCode'=>array('name'=>'responseCode','type'=>'xsd:string'),
            'responseDesc'=>array('name'=>'responseDesc','type'=>'xsd:string')
        )
);

$server->wsdl->addComplexType(
        'updateUserProfileResponseDetail'
        ,'complexType'
        ,'struct'
        ,'all'
        ,''
        ,array(  
            'refId'  => array('name' => 'refId','type' => 'xsd:string'),
            'dateTime'  => array('name' => 'dateTime','type' => 'xsd:string'),
            'UserId' => array('name'=>'UserId','type'=>'xsd:string'),
            'GenderCode'=>array('name'=>'GenderCode','type'=>'xsd:string'),
            'TitleCode'=>array('name'=>'TitleCode','type'=>'xsd:string'),
            'FirstName'=>array('name'=>'FirstName','type'=>'xsd:string'),
            'MiddleName'=>array('name'=>'MiddleName','type'=>'xsd:string'),
            'LastName'=>array('name'=>'LastName','type'=>'xsd:string'),
            'Address1'=>array('name'=>'Address1','type'=>'xsd:string'),
            'Address2'=>array('name'=>'Address2','type'=>'xsd:string'),
            'Address3'=>array('name'=>'Address3','type'=>'xsd:string'),
            'Street'=>array('name'=>'Street','type'=>'xsd:string'),
            'SubDistrictCode'=>array('name'=>'SubDistrictCode','type'=>'xsd:string'),
            'DistrictCode'=>array('name'=>'DistrictCode','type'=>'xsd:string'),
            'ProvinceCode'=>array('name'=>'ProvinceCode','type'=>'xsd:string'),
            'PostCode'=>array('name'=>'PostCode','type'=>'xsd:string'),
            'Telephone'=>array('name'=>'Telephone','type'=>'xsd:string'),
            'MobilePhone'=>array('name'=>'MobilePhone','type'=>'xsd:string'),
            'CreateBy'=>array('name'=>'CreateBy','type'=>'xsd:string'),
            'CreateDate'=>array('name'=>'CreateDate','type'=>'xsd:string'),
            'UpdateBy'=>array('name'=>'UpdateBy','type'=>'xsd:string'),
            'UpdateDate'=>array('name'=>'UpdateDate','type'=>'xsd:string')
        )
);

$server->wsdl->addComplexType(
        'updateUserProfileResponse'
        ,'complexType'
        ,'struct'
        ,'all'
        ,''
        ,array(
            'updateUserProfileResponseHeader'=>array('name' => 'updateUserProfileResponseHeader','type' => 'tns:updateUserProfileResponseHeader'),
            'updateUserProfileResponseDetail'=>array('name' => 'updateUserProfileResponseDetail','type' => 'tns:updateUserProfileResponseDetail')
        )
);


// end update user profile
// before change password

$server->wsdl->addComplexType(
        'changePasswordRequestHeader'
        ,'complexType'
        ,'struct'
        ,'all'
        ,''
        ,array(  
            'refId'  => array('name' => 'refId','type' => 'xsd:string'),
            'dateTime'  => array('name' => 'dateTime','type' => 'xsd:string')
        )
);

$server->wsdl->addComplexType(
        'changePasswordRequestDetail'
        ,'complexType'
        ,'struct'
        ,'all'
        ,''
        ,array( 
            'refId'=>array('name'=>'refId','type'=>'xsd:string'),
            'dateTime'=>array('name'=>'dateTime','type'=>'xsd:string'),
            'userId' => array('name'=>'userId','type'=>'xsd:string'),
            'oldPassword'  => array('name' => 'oldPassword','type' => 'xsd:string'),
            'newPassword'  => array('name' => 'newPassword','type' => 'xsd:string')
        )
);

$server->wsdl->addComplexType(
        'changePasswordRequest'
        ,'complexType'
        ,'struct'
        ,'all'
        ,''
        ,array(
            'changePasswordRequestHeader'=>array('name' => 'changePasswordRequestHeader','type' => 'tns:changePasswordRequestHeader'),
            'changePasswordRequestDetail'=>array('name' => 'changePasswordRequestDetail','type' => 'tns:changePasswordRequestDetail')
        )
);

$server->wsdl->addComplexType(
        'changePasswordResponseHeader'
        ,'complexType'
        ,'struct'
        ,'all'
        ,''
        ,array(  
            'refId'  => array('name' => 'refId','type' => 'xsd:string'),
            'dateTime'  => array('name' => 'dateTime','type' => 'xsd:string'),
            'responseCode'=>array('name'=>'responseCode','type'=>'xsd:string'),
            'responseDesc'=>array('name'=>'responseDesc','type'=>'xsd:string')
        )
);

$server->wsdl->addComplexType(
        'changePasswordResponse'
        ,'complexType'
        ,'struct'
        ,'all'
        ,''
        ,array(
            'changePasswordResponseHeader'=>array('name' => 'changePasswordResponseHeader','type' => 'tns:changePasswordResponseHeader')
        )
);

// end change password
////////////////////////////////////////////////////////////////////////
///// Register 

$server->register(
                'UserProfileOperation.createUserProfile',     
                array('createUserProfileRequest'=>'tns:createUserProfileRequest'), 
                array('updateUserProfileResponse'=>'tns:updateUserProfileResponse'),
                $namespace,
                false,
                'rpc',
                'encoded',
                'LoginOperation'
);

$server->register(
                'UserProfileOperation.updateUserProfile',     
                array('updateUserProfileRequest'=>'tns:updateUserProfileRequest'), 
                array('updateUserProfileResponse'=>'tns:updateUserProfileResponse'),
                $namespace,
                false,
                'rpc',
                'encoded',
                'LoginOperation'
);

$server->register(
                'UserProfileOperation.changePassword',     
                array('changePasswordRequest'=>'tns:changePasswordRequest'), 
                array('changePasswordResponse'=>'tns:changePasswordResponse'),
                $namespace,
                false,
                'rpc',
                'encoded',
                'LoginOperation'
);

////
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
exit();
?>
